<div id="add-new-product">
    <form action="<?php echo $this->baseUrl('admin/product/add') ?>" method="post" enctype="multipart/form-data" id="form-add">
        <div class="left">
            <div class="input"><?php echo $this->form->product_name?></div>
            <div class="input"><?php echo $this->form->product_price?></div>
            <div class="input"><?php echo $this->form->product_warranty?></div>
            
        </div>
        <div class="right">
            <div class="input"><?php echo $this->form->manufacture_id?></div>
            <div class="input"><?php echo $this->form->product_image?> </div>                      
        </div>
        <div class="input"><?php echo $this->form->product_promotion?></div>
        <div class="input"><?php echo $this->form->product_description?></div>
        <div class="button"><?php echo $this->form->add;?>
                            <?php echo $this->form->reset;?>
                            <?php echo $this->form->cancel;?>
                            </div>
    </form>
</div>
<?php //echo $this->form?>
<script>
var editor = CKEDITOR.replace( 'product_description',{
	uiColor : '#9AB8F3',
	language:'vi',
	skin:'kama',	
   
	filebrowserImageBrowseUrl : '<?php echo $this->baseUrl("/")?>public/admin/ckeditor/ckfinder/ckfinder.html?Type=Images',
filebrowserFlashBrowseUrl : '<?php echo $this->baseUrl("/")?>public/admin/ckeditor/ckfinder/ckfinder.html?Type=Flash',
filebrowserImageUploadUrl : '<?php echo $this->baseUrl("/")?>public/admin/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
filebrowserFlashUploadUrl : '<?php echo $this->baseUrl("/")?>public/admin/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
filebrowserUploadUrl : '<?php echo $this->baseUrl("/")?>/public/admin/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
		 	
	toolbar:[
	['Source','-','Save','NewPage','Preview','-','Templates'],
	['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'],
	['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
	['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
	['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
	['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
	['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
	['Link','Unlink','Anchor'],
	['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
	['Styles','Format','Font','FontSize'],
	['TextColor','BGColor'],
	['Maximize', 'ShowBlocks','-','About']
	]
});		

</script>
<script>
    $(function(){
      // createEditor("description");
       
       //create thumb nail
       $("#product_image").change(function(e){
            // get image
            var thisObj = $(this);
            var url = URL.createObjectURL(e.target.files[0]);
            var img = new Image();
            
            var canvas = document.createElement("canvas");
            canvas.setAttribute("class","thumb");
            
            var ctx = canvas.getContext('2d');
            img.onload = function() {
                var h = 140, per = img.width/img.height;
                var w = h*per;
                canvas.height = h;
                canvas.width = w;
                $(".thumb").remove();
                thisObj.parent().append(canvas);
                ctx.drawImage(img, 0, 0,w ,h);    
            }
            img.src = url;   
       })
    });
</script>

